using System;
using System.Data.Linq.Mapping;
using CoreLibrary;
using CoreLibrary.Date;

namespace Entities.DataBase.Persistent {

    [Table(Name = "D_USER")]
    public class User {

        public User() {
            UserId      = GuidUtil.GuidN();
            DateCreated = DateTime.UtcNow;
            DateUpdated = DateUtil.Epoch;
        }

        [Column(IsPrimaryKey = true, IsDbGenerated = true)]
        public int Id { get; set; }

        [Column(Name = "USER_ID")]
        public string UserId { get; set; }

        [Column(Name = "TITLE")]
        public string Title { get; set; }

        [Column(Name = "FIRST_NAME")]
        public string FirstName { get; set; }

        [Column(Name = "MIDDLE_NAME")]
        public string MiddleName { get; set; }

        [Column(Name = "LAST_NAME")]
        public string LastName { get; set; }

        [Column(Name = "EMAIL")]
        public string Email { get; set; }

        [Column(Name = "LOG_IN_NAME")]
        public string LogInName { get; set; }

        [Column(Name = "PASSWORD")]
        public string Password { get; set; }

        [Column(Name = "USER_ROLE")]
        public int UserRole { get; set; }

        [Column(Name = "ENABLED")]
        public bool Enabled { get; set; }

        [Column(Name = "DATE_CREATED")]
        public DateTime DateCreated { get; set; }

        [Column(Name = "DATE_UPDATED")]
        public DateTime DateUpdated { get; set; }

        public string FullName {
            get {
                return StringUtil.Join(" ", new[] {
                       Util.GetString(LastName),
                       Util.GetString(MiddleName),
                       Util.GetString(FirstName),
                });
            }
        }

    }
}